home *** CD-ROM | disk | FTP | other *** search
-
- #include "SelectedObject.h"
- #include "pcgWindow.h"
- #ifndef __GNUC__
- #include <clib/exec_protos.h>
- #include <clib/intuition_protos.h>
- #include <clib/graphics_protos.h>
- #endif
- #ifdef __GNUC__
- #include <proto/exec.h>
- #include <proto/intuition.h>
- #include <proto/graphics.h>
- #endif
- #ifdef __SASC
- #include <proto/exec.h>
- #include <proto/intuition.h>
- #include <proto/graphics.h>
- #endif
- #include "amigamem.h"
- #include <stdio.h>
- #include "ImageBob.h"
- #include "BuilderMethods.h" /* Add prototypes for InitImageBob & CleanUpImageBob -- EDB */
-
- void so_DrawHighlight( RastPort *rport,
- SelectedObject *si,
- Point delta )
- {
- Point size, location;
- USHORT xmin, xmax, ymin, ymax;
-
- if( si == NULL ) return;
-
- size = Size( si->PObject );
- location = Location( si->PObject );
-
- xmin = location.x + delta.x;
- xmax = xmin + size.x-1;
- ymin = location.y + delta.y;
- ymax = ymin + size.y-1;
-
- SetDrMd( rport, COMPLEMENT );
- RectFill( rport, xmin, ymin, xmax, ymax );
- }
-
-
- void so_DrawHighlights( RastPort *rport,
- SelectedObject *si,
- Point delta )
- {
-
- for( ; si != NULL; si = si->Next )
- so_DrawHighlight( rport, si, delta );
- }
-
- SelectedObject *so_SelectPObject( SelectedObject **chain,
- GraphicObject *obj )
- {
- SelectedObject *prev_si = NULL;
- SelectedObject *si = NULL;
- SelectedObject *new_si = NULL;
-
- /* printf("Select object \"%s\", ", obj->PObjectName ); */
- /* printf("nSelected=%d\n", self->nSelected ); */
-
- if( *chain )
- {
- for( si = *chain; si != NULL; si = si->Next )
- {
- /* printf("checking object \"%s\" for match to \"%s\"\n", */
- /* si->PObject->PObjectName, obj->PObjectName ); */
-
- if( si->PObject == obj )
- {
- /* printf("They match!\n"); */
- return NULL; /* PObject is already selected. */
- }
-
- prev_si = si;
- }
- }
-
- /* printf("No match\n"); */
- if( new_si = (SelectedObject *)Amalloc( sizeof( SelectedObject ) ) )
- {
- new_si->Next = NULL;
- new_si->PObject = obj;
-
- if( *chain )
- {
- /* printf( "added selection to tail.\n" ); */
- prev_si->Next = new_si;
- }
- else
- {
- /* printf( "This is the first selection.\n" ); */
- *chain = new_si;
- }
-
- }
- else
- printf( "Couldn't allocate new_si\n" );
-
- return new_si;
- }
-
-
-
- void so_InitImages( SelectedObject *object_chain,
- struct RastPort *rport,
- Point offset )
- {
- SelectedObject *object;
- Point location;
-
- /* Get images of objects */
- for( object = object_chain;
- object != NULL;
- object = object->Next )
- {
- if( InitImageBob( object->PObject, &object->iBob ) )
- {
- /* printf( "got image bob\n" ); */
-
- /* use Screen relative coordinates. */
- location = Location( object->PObject );
-
- object->iBob.VSprite.X = offset.x + location.x;
- object->iBob.VSprite.Y = offset.y + location.y;
-
- AddBob( &object->iBob.Bob, rport );
- /* printf( "added bob to list.\n" ); */
- }
-
- }
- }
-
- void so_CleanUpImages( SelectedObject *object_chain )
- {
- SelectedObject *object;
-
- /* Get images of objects */
- for( object = object_chain;
- object != NULL;
- object = object->Next )
- {
- RemBob( &object->iBob.Bob );
- CleanUpImageBob( object->PObject, &object->iBob );
- }
- }
-
-
- void so_Drag( SelectedObject *object_chain,
- pcgWindow *pwindow,
- Point mouse )
-
- {
- struct RastPort *screen_rport;
- struct ViewPort *screen_vport;
- struct Window *iwindow;
- ULONG IDCMPbuf;
- Point window_loc;
-
- iwindow = iWindow( pwindow );
- screen_rport = &iwindow->WScreen->RastPort;
- screen_vport = &iwindow->WScreen->ViewPort;
-
-
- /* translate 'mouse' into screen coordinates. */
- window_loc = Location( (struct GraphicObject *)pwindow );
- mouse.x += window_loc.x;
- mouse.y += window_loc.y;
-
- so_InitImages( object_chain, screen_rport, window_loc );
-
- IDCMPbuf = IDCMPFlags( (struct Interactor *)pwindow );
- SetIDCMPFlags( pwindow, IDCMPbuf | MOUSEMOVE );
-
- Forbid();
- iwindow->Flags |= RMBTRAP; /* right mouse trap. */
- Permit();
-
- DrawGList( screen_rport, screen_vport ); /* draw bobs. */
-
-
-
- /*** clean up ****/
- Forbid();
- iwindow->Flags &= ~RMBTRAP; /* right mouse trap. */
- Permit();
-
- SetIDCMPFlags( pwindow, IDCMPbuf );
- so_CleanUpImages( object_chain );
- DrawGList( screen_rport, screen_vport ); /* erase bobs. */
-
- }